<include file="Public:header" />
<style type="text/css">
    tr.menu-content td select {
        width:140px;
    }
</style>
<div class="alert alert-info">
    供货种类管理
</div>
<p class="text-center" style="font-weight:bold">本周菜单： {$startDate} 至 {$endDate}</p>
<form action="" method="post" onsubmit="return ajax_submit(this);">
    <table class="table table-bordered">
        <tr>
            <th>星期一</th>
            <th>星期二</th>
            <th>星期三</th>
            <th>星期四</th>
            <th>星期五</th>
            <th>星期六</th>
            <th>星期日</th>
        </tr>
        <tr class="menu-content">
            <if condition="$toWeekMenu eq ''">
                <volist name="tdList" id="week">
                <td>
                    <p><a href="" class="btn btn-primary" data="{$week}" onclick="return addItem(this);">增加一行</a></p>
                    <div class="copy-{$week}">
                        <select name="food_content_{$week}[]">
                            <option value="-1">-- 请选择一道菜式 --</option>
                            <volist name="foodData" id="val">
                                <option value="{$val.id}">{$val.food_name}</option>
                            </volist>
                        </select>
                    </div>
                </td>
                </volist>
            <else />
                <volist name="toWeekMenu" id="menu" key="k">
                    <td>
                        <p><a href="" class="btn btn-primary" data="{$k}" onclick="return addItemOnUp(this);">增加一个菜式</a></p>
                        <if condition="$menu">
                            <volist name="menu" id="foodId">
                                <div class="copy-{$k}">
                                    <select name="food_content_{$k}[]">
                                        <option value="-1">-- 请选择一道菜式 --</option>
                                        <volist name="foodData" id="val">
                                            <if condition="$val['id'] eq $foodId">
                                                <option value="{$val.id}" selected>{$val.food_name}</option>
                                            <else />
                                                <option value="{$val.id}">{$val.food_name}</option>
                                            </if>
                                        </volist>
                                    </select>
                                </div>

                                <div class="copy-temp-{$k}" style="display:none;">
                                    <select name="food_content_{$k}[]">
                                        <option value="-1">-- 请选择一道菜式 --</option>
                                        <volist name="foodData" id="val">
                                            <option value="{$val.id}">{$val.food_name}</option>
                                        </volist>
                                    </select>
                                </div>
                            </volist>
                        <else />
                            <div class="copy-{$k}">
                                <select name="food_content_{$k}[]">
                                    <option value="-1">-- 请选择一道菜式 --</option>
                                    <volist name="foodData" id="val">
                                        <option value="{$val.id}">{$val.food_name}</option>
                                    </volist>
                                </select>
                            </div>
                            <div class="copy-temp-empty" style="display:none;">
                                <select name="food_content_{$k}[]">
                                    <option value="-1">-- 请选择一道菜式 --</option>
                                    <volist name="foodData" id="val">
                                        <option value="{$val.id}">{$val.food_name}</option>
                                    </volist>
                                </select>
                            </div>
                        </if>
                    </td>
                </volist>
            </if>
        </tr>
        <tr><td colspan="7" style="text-align:center"><input type="submit" value="确定菜单" class="btn btn-warning"/></td></tr>
        <if condition="$operation eq 'update'">
            <tr><td colspan="7" style="text-align:center"><a href="__URL__/createOrder/id/{$id}" class="btn btn-primary">形成采购清单</a></td></tr>
        </if>
    </table>
    <input type="hidden" name="send" />
    <if condition="$operation eq 'update'"><input type="hidden" name="id" value="{$id}"/></if>
</form>
<div class="pagination">
    {$page}
</div>
<a href="__URL__/showHistory" class="btn btn-info" style="float:right;margin-right:25px;">查看历史菜单</a>
<include file="Public:check"/>
<script type="text/javascript">

    function addItem(_this)
    {
        var week = $(_this).attr('data');
        var copy = $('div.copy-'+week).html();
        $('div.copy-'+week).parent().append(copy+'<br />');
        return false;
    }

    function addItemOnUp(_this)
    {
        var week = $(_this).attr('data');
        var copy = $('div.copy-temp-'+week).html();
        if(copy == undefined) copy = $('div.copy-temp-empty').html();
        $('div.copy-'+week).parent().append(copy+'<br />');
        return false;
    }

</script>
</body>
</html>